Merge pull request #343 from alias1/disable-agents-tweaks

Disable agents tweaks

Andrew Cantino 10 lat temu
rodzic
commit
721487bdc2

+ 15 - 4
app/assets/stylesheets/application.css.scss.erb

@@ -136,10 +136,8 @@ span.not-applicable:after {
136 136
 
137 137
 // Disabled
138 138
 
139
-tr.agent-disabled {
140
-  td {
141
-    opacity: 0.5;
142
-  }
139
+.agent-disabled {
140
+  opacity: 0.5;
143 141
 }
144 142
 
145 143
 // Fix JSON Editor
@@ -147,3 +145,16 @@ tr.agent-disabled {
147 145
 .json-editor blockquote {
148 146
   font-size: 14px;
149 147
 }
148
+
149
+// Bootstrappy colour styles
150
+.color-danger {
151
+  color: #d9534f;
152
+}
153
+
154
+.color-warning {
155
+  color: #f0ad4e;
156
+}
157
+
158
+.color-success {
159
+  color: #5cb85c;
160
+}

+ 2 - 2
app/helpers/application_helper.rb

@@ -9,11 +9,11 @@ module ApplicationHelper
9 9
 
10 10
   def working(agent)
11 11
     if agent.disabled?
12
-      '<span class="label label-warning">Disabled</span>'.html_safe
12
+      link_to '<span class="label label-warning">Disabled</span>'.html_safe, agent_path(agent)
13 13
     elsif agent.working?
14 14
       '<span class="label label-success">Yes</span>'.html_safe
15 15
     else
16
-      link_to '<span class="label btn-danger">No</span>'.html_safe, agent_path(agent, :tab => (agent.recent_error_logs? ? 'logs' : 'details'))
16
+      link_to '<span class="label label-danger">No</span>'.html_safe, agent_path(agent, :tab => (agent.recent_error_logs? ? 'logs' : 'details'))
17 17
     end
18 18
   end
19 19
 end

+ 41 - 0
app/views/agents/_action_menu.html.erb

@@ -0,0 +1,41 @@
1
+<ul class="dropdown-menu" role="menu">
2
+  <% if agent.can_be_scheduled? %>
3
+    <li>
4
+      <%= link_to '<span class="color-success glyphicon glyphicon-refresh"></span> Run'.html_safe, run_agent_path(agent, :return => returnTo), method: :post, :tabindex => "-1" %>
5
+    </li>
6
+  <% end %>
7
+
8
+  <li>
9
+    <%= link_to '<span class="glyphicon glyphicon-eye-open"></span> Show'.html_safe, agent_path(agent) %>
10
+  </li>
11
+
12
+  <li class="divider"></li>
13
+
14
+  <li>
15
+    <%= link_to '<span class="glyphicon glyphicon-pencil"></span> Edit agent'.html_safe, edit_agent_path(agent) %>
16
+  </li>
17
+
18
+  <li>
19
+    <%= link_to '<span class="glyphicon glyphicon-plus"></span> Clone agent'.html_safe, new_agent_path(id: agent), :tabindex => "-1" %>
20
+  </li>
21
+
22
+  <li>
23
+    <% if agent.disabled? %>
24
+      <%= link_to '<i class="glyphicon glyphicon-play"></i> Enable agent'.html_safe, agent_path(agent, :agent => { :disabled => false }, :return => returnTo), :method => :put %>
25
+    <% else %>
26
+      <%= link_to '<i class="glyphicon glyphicon-pause"></i> Disable agent'.html_safe, agent_path(agent, :agent => { :disabled => true }, :return => returnTo), :method => :put %>
27
+    <% end %>
28
+  </li>
29
+
30
+  <li class="divider"></li>
31
+
32
+  <% if agent.can_create_events? && agent.events.count > 0 %>
33
+    <li>
34
+      <%= link_to '<span class="color-danger glyphicon glyphicon-trash"></span> Delete all events'.html_safe, remove_events_agent_path(agent), method: :delete, data: {confirm: 'Are you sure you want to delete ALL events for this Agent?'}, :tabindex => "-1" %>
35
+    </li>
36
+  <% end %>
37
+
38
+  <li>
39
+    <%= link_to '<span class="color-danger glyphicon glyphicon-remove"></span> Delete agent'.html_safe, agent_path(agent), method: :delete, data: { confirm: 'Are you sure?' }, :tabindex => "-1" %>
40
+  </li>
41
+</ul>

+ 13 - 17
app/views/agents/index.html.erb

@@ -19,41 +19,41 @@
19 19
           </tr>
20 20
 
21 21
           <% @agents.each do |agent| %>
22
-            <tr class='<%= "agent-disabled" if agent.disabled? %>'>
23
-              <td>
24
-                <%= agent.name %>
22
+            <tr>
23
+              <td class='<%= "agent-disabled" if agent.disabled? %>'>
24
+                <%= link_to agent.name, agent_path(agent) %>
25 25
                 <br/>
26 26
                 <span class='text-muted'><%= agent.short_type.titleize %></span>
27 27
               </td>
28
-              <td>
28
+              <td class='<%= "agent-disabled" if agent.disabled? %>'>
29 29
                 <% if agent.can_be_scheduled? %>
30 30
                   <%= agent.schedule.to_s.humanize.titleize %>
31 31
                 <% else %>
32 32
                   <span class='not-applicable'></span>
33 33
                 <% end %>
34 34
               </td>
35
-              <td>
35
+              <td class='<%= "agent-disabled" if agent.disabled? %>'>
36 36
                 <% if agent.can_be_scheduled? %>
37 37
                   <%= agent.last_check_at ? time_ago_in_words(agent.last_check_at) + " ago" : "never" %>
38 38
                 <% else %>
39 39
                   <span class='not-applicable'></span>
40 40
                 <% end %>
41 41
               </td>
42
-              <td>
42
+              <td class='<%= "agent-disabled" if agent.disabled? %>'>
43 43
                 <% if agent.can_create_events? %>
44 44
                   <%= agent.last_event_at ? time_ago_in_words(agent.last_event_at) + " ago" : "never" %>
45 45
                 <% else %>
46 46
                   <span class='not-applicable'></span>
47 47
                 <% end %>
48 48
               </td>
49
-              <td>
49
+              <td class='<%= "agent-disabled" if agent.disabled? %>'>
50 50
                 <% if agent.can_receive_events? %>
51 51
                   <%= agent.last_receive_at ? time_ago_in_words(agent.last_receive_at) + " ago" : "never" %>
52 52
                 <% else %>
53 53
                   <span class='not-applicable'></span>
54 54
                 <% end %>
55 55
               </td>
56
-              <td>
56
+              <td class='<%= "agent-disabled" if agent.disabled? %>'>
57 57
                 <% if agent.can_create_events? %>
58 58
                   <%= link_to(agent.events_count || 0, events_path(:agent => agent.to_param)) %>
59 59
                 <% else %>
@@ -62,15 +62,11 @@
62 62
               </td>
63 63
               <td><%= working(agent) %></td>
64 64
               <td>
65
-                <div class="btn-group btn-group-xs">
66
-                  <%= link_to 'Show', agent_path(agent), class: "btn btn-default" %>
67
-                  <%= link_to 'Edit', edit_agent_path(agent), class: "btn btn-default" %>
68
-                  <%= link_to 'Delete', agent_path(agent), method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-default" %>
69
-                  <% if agent.can_be_scheduled? && !agent.disabled? %>
70
-                    <%= link_to 'Run', run_agent_path(agent, :return => "index"), method: :post, class: "btn btn-default" %>
71
-                  <% else %>
72
-                    <%= link_to 'Run', "#", class: "btn btn-default disabled" %>
73
-                  <% end %>
65
+                <div class="btn-group">
66
+                  <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
67
+                    <span class="glyphicon glyphicon-th-list"></span> Actions <span class="caret"></span>
68
+                  </button>
69
+                  <%= render 'action_menu', :agent => agent, :returnTo => "index" %>
74 70
                 </div>
75 71
               </td>
76 72
             </tr>

+ 7 - 32
app/views/agents/show.html.erb

@@ -2,6 +2,8 @@
2 2
   <div class='row'>
3 3
     <div class='col-md-2'>
4 4
         <ul class="nav nav-pills nav-stacked" id="show-tabs">
5
+          <li><%= link_to '<span class="glyphicon glyphicon-chevron-left"></span> Back'.html_safe, agents_path %></li>
6
+
5 7
           <% if agent_show_view(@agent).present? %>
6 8
             <li class='active'><a href="#summary" data-toggle="tab"><span class='glyphicon glyphicon-picture'></span> Summary</a></li>
7 9
             <li><a href="#details" data-toggle="tab"><span class='glyphicon glyphicon-indent-left'></span> Details</a></li>
@@ -9,45 +11,18 @@
9 11
             <li class='disabled'><a><span class='glyphicon glyphicon-picture'></span> Summary</a></li>
10 12
             <li class='active'><a href="#details" data-toggle="tab"><span class='glyphicon glyphicon-indent-left'></span> Details</a></li>
11 13
           <% end %>
14
+
12 15
           <li><a href="#logs" data-toggle="tab" data-agent-id="<%= @agent.id %>" class='<%= @agent.recent_error_logs? ? 'recent-errors' : '' %>'><span class='glyphicon glyphicon-list-alt'></span> Logs</a></li>
13 16
 
14 17
           <% if @agent.can_create_events? && @agent.events.count > 0 %>
15 18
             <li><%= link_to '<span class="glyphicon glyphicon-random"></span> Events'.html_safe, events_path(:agent => @agent.to_param) %></li>
19
+          <% else %>
20
+            <li class='disabled'><a><span class='glyphicon glyphicon-random'></span> Events</a></li>
16 21
           <% end %>
17
-          <li><%= link_to '<span class="glyphicon glyphicon-chevron-left"></span> Back'.html_safe, agents_path %></li>
18
-          <li><%= link_to '<span class="glyphicon glyphicon-pencil"></span> Edit'.html_safe, edit_agent_path(@agent) %></li>
19 22
 
20 23
           <li class="dropdown">
21
-            <a class="dropdown-toggle" data-toggle="dropdown" href="#">Actions <b class="caret"></b></a>
22
-            <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
23
-              <% if @agent.can_be_scheduled? %>
24
-                <li>
25
-                  <%= link_to '<span class="glyphicon glyphicon-refresh"></span> Run'.html_safe, run_agent_path(@agent, :return => "show"), method: :post, :tabindex => "-1" %>
26
-                </li>
27
-              <% end %>
28
-
29
-              <% if @agent.can_create_events? && @agent.events.count > 0 %>
30
-                <li>
31
-                  <%= link_to '<span class="glyphicon glyphicon-trash"></span> Delete all events'.html_safe, remove_events_agent_path(@agent), method: :delete, data: {confirm: 'Are you sure you want to delete ALL events for this Agent?'}, :tabindex => "-1" %>
32
-                </li>
33
-              <% end %>
34
-
35
-              <li>
36
-                <%= link_to '<span class="glyphicon glyphicon-plus"></span> Clone'.html_safe, new_agent_path(id: @agent), :tabindex => "-1" %>
37
-              </li>
38
-
39
-              <li>
40
-                <% if @agent.disabled? %>
41
-                  <%= link_to '<i class="glyphicon glyphicon-play"></i> Enable agent'.html_safe, agent_path(@agent, :agent => { :disabled => false }, :return => "show"), :method => :put %>
42
-                <% else %>
43
-                  <%= link_to '<i class="glyphicon glyphicon-pause"></i> Disable agent'.html_safe, agent_path(@agent, :agent => { :disabled => true }, :return => "show"), :method => :put %>
44
-                <% end %>
45
-              </li>
46
-
47
-              <li>
48
-                <%= link_to '<span class="glyphicon glyphicon-remove"></span> Delete'.html_safe, agent_path(@agent), method: :delete, data: { confirm: 'Are you sure?' }, :tabindex => "-1" %>
49
-              </li>
50
-            </ul>
24
+            <a class="dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-th-list"></span> Actions <span class="caret"></span></a>
25
+            <%= render 'action_menu', :agent => @agent, :returnTo => "show" %>
51 26
           </li>
52 27
         </ul>
53 28
       </div>